<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>cute-transfer: E:/CODE/CPPpro/cute-transfer/Msg&amp;FileTransfer/connection.h源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">cute-transfer</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">E:/CODE/CPPpro/cute-transfer/Msg&amp;FileTransfer/connection.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef CONNECTION_H_INCLUDED</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define CONNECTION_H_INCLUDED</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;cstdio&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;pthread.h&gt;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;winsock2.h&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;conFile.h&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;msg.h&quot;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00034"></a>00034 
<a name="l00037"></a><a class="code" href="class_connection.html">00037</a> <span class="keyword">class </span><a class="code" href="class_connection.html" title="连接类">Connection</a>{
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">public</span>:
<a name="l00041"></a>00041     <span class="keyword">enum</span> {
<a name="l00042"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a6ac87b5ad88277e855c7069c92c1a479">00042</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a6ac87b5ad88277e855c7069c92c1a479">CI_MSG</a> = 0,         
<a name="l00043"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a989319b5032ad18954665d76be3eb774">00043</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a989319b5032ad18954665d76be3eb774">CI_FILENEW</a>,         
<a name="l00044"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a4ff6e27604edfac1c02ccfcc2d9b283c">00044</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a4ff6e27604edfac1c02ccfcc2d9b283c">CI_FILESTARTSEND</a>,   
<a name="l00045"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4ad3d543e05399f24d0e3aa51125bfe256">00045</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4ad3d543e05399f24d0e3aa51125bfe256">CI_FILESENDCANCEL</a>,  
<a name="l00046"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4aa0369367db1b811c01bce029a8f47d2a">00046</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4aa0369367db1b811c01bce029a8f47d2a">CI_FILECONTENT</a>,     
<a name="l00047"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4ab1b973f17f2c75ba75ba03fbd5ba5ccc">00047</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4ab1b973f17f2c75ba75ba03fbd5ba5ccc">CI_FILECLOSE</a>,       
<a name="l00048"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a42c1f798607deead31db115c4a382b59">00048</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a42c1f798607deead31db115c4a382b59">CI_FILEMD5</a>,         
<a name="l00049"></a><a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a26d0ecb83471911a4f52faebbdca9da7">00049</a>         <a class="code" href="class_connection.html#acea45320bf437182b6df56d238f127d4a26d0ecb83471911a4f52faebbdca9da7">CI_FILEEND</a>          
<a name="l00051"></a>00051     };
<a name="l00052"></a>00052 
<a name="l00056"></a><a class="code" href="struct_connection_1_1_____connection_info.html">00056</a>     <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct_connection_1_1_____connection_info.html">__ConnectionInfo</a>{
<a name="l00057"></a>00057         <span class="keywordtype">char</span> type;
<a name="l00058"></a>00058         <span class="keywordtype">char</span> content[5005];
<a name="l00059"></a>00059 
<a name="l00060"></a>00060     } <a class="code" href="class_connection.html#a99cb53a80cd37966cc4f7e922c5f2ccc">ConInfo</a>;
<a name="l00061"></a>00061 
<a name="l00065"></a>00065     <a class="code" href="class_connection.html#a9de94289ca6259f94ef6aeba3b134a77">Connection</a>();
<a name="l00066"></a>00066 
<a name="l00074"></a>00074     <a class="code" href="class_connection.html#a9de94289ca6259f94ef6aeba3b134a77">Connection</a>(<span class="keyword">const</span> SOCKADDR_IN &amp;newAddr, <span class="keywordtype">int</span> newRecvfd = 0);
<a name="l00075"></a>00075 
<a name="l00079"></a>00079     <a class="code" href="class_connection.html#a2e4352edf667bea83001569e9da8a24d">~Connection</a>();
<a name="l00080"></a>00080 
<a name="l00084"></a>00084     <span class="keyword">static</span> <span class="keywordtype">void</span> *<a class="code" href="class_connection.html#a9f3f51055f4c70eeef82a7ba68e85e97">thread_recv</a>(<span class="keywordtype">void</span> *arg);
<a name="l00085"></a>00085 
<a name="l00089"></a>00089     <span class="keyword">static</span> <span class="keywordtype">void</span> *<a class="code" href="class_connection.html#a3f7349a98ae89d34f50dfbe839e14a13">thread_sendfile</a>(<span class="keywordtype">void</span> *arg);
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 
<a name="l00099"></a>00099     <span class="keywordtype">bool</span> <a class="code" href="class_connection.html#a6338a92b3fc9db9d1c82f537aecd1c10">compare</a>(<span class="keyword">const</span> <a class="code" href="class_connection.html" title="连接类">Connection</a> &amp; cpCon);
<a name="l00100"></a>00100 
<a name="l00111"></a>00111     <span class="keywordtype">bool</span> <a class="code" href="class_connection.html#ac8c5ffaeee6b7ac1ac3b4eb27a1f6193">isExist</a>(<span class="keyword">const</span> SOCKADDR_IN &amp; cpAddr);
<a name="l00112"></a>00112 
<a name="l00118"></a>00118     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a2ce3e68b2f6e09a86591b3fc8818fac3">getRecvfd</a>();
<a name="l00119"></a>00119 
<a name="l00125"></a>00125     <span class="keywordtype">void</span> <a class="code" href="class_connection.html#a76abdfdf3ba06bb8bfbc95d8cc3e9d8b">setRecvfd</a>(<span class="keywordtype">int</span> newRecvfd);
<a name="l00126"></a>00126 
<a name="l00130"></a>00130     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a3c0a490cbc7337b7dda84ef72f3b5632">startCon</a>();
<a name="l00131"></a>00131 
<a name="l00135"></a>00135     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a4dbf656f9bb517b2effa9d40ff49eabd">closeCon</a>();
<a name="l00136"></a>00136 
<a name="l00142"></a>00142     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a6fa2bc6d6be7049487cce4135c3657e6">sendMsg</a>(<span class="keyword">const</span> std::string msg);
<a name="l00143"></a>00143 
<a name="l00149"></a>00149     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a02edd03264480bcfec195f88c65385c5">addFileToSend</a>(<span class="keyword">const</span> std::string &amp;filepath);
<a name="l00150"></a>00150 
<a name="l00154"></a>00154     <span class="keywordtype">int</span> <a class="code" href="class_connection.html#a34ff84664e4b728d4f59947dd45788a2">testConnect</a>();
<a name="l00155"></a>00155 
<a name="l00161"></a>00161     SOCKADDR_IN <a class="code" href="class_connection.html#a3c590179abcedd53b3bae4fd3046a374">getSelfAddr</a>();
<a name="l00162"></a>00162 <span class="keyword">private</span>:
<a name="l00163"></a>00163 
<a name="l00167"></a>00167     SOCKET m_sendfd;
<a name="l00168"></a>00168 
<a name="l00172"></a>00172     SOCKET m_recvfd;
<a name="l00173"></a>00173 
<a name="l00177"></a>00177     SOCKADDR_IN m_conaddr;
<a name="l00178"></a>00178 
<a name="l00182"></a>00182     pthread_t m_recvPid;
<a name="l00183"></a>00183 
<a name="l00187"></a>00187     pthread_t m_sendfilePid;
<a name="l00188"></a>00188 
<a name="l00192"></a>00192     std::map&lt;int, FileStatus&gt; m_FilesRecv;
<a name="l00193"></a>00193 
<a name="l00197"></a>00197     std::map&lt;int, FileStatus&gt; m_FilesSend;
<a name="l00198"></a>00198 
<a name="l00202"></a>00202     <span class="keywordtype">void</span> resetSendpid();
<a name="l00203"></a>00203 
<a name="l00207"></a>00207     <span class="keywordtype">int</span> getFileKey();
<a name="l00208"></a>00208 
<a name="l00216"></a>00216     <span class="keywordtype">int</span> writeFileContent(<a class="code" href="struct_connection_1_1_____connection_info.html">ConInfo</a> &amp; fileCon, std::string &amp;filepath, <span class="keywordtype">int</span> &amp;nProgress);
<a name="l00217"></a>00217 
<a name="l00221"></a>00221     <span class="keywordtype">int</span> closeFile(<a class="code" href="struct_connection_1_1_____connection_info.html">ConInfo</a> &amp;conInfo, <span class="keywordtype">bool</span> &amp;md5_check);
<a name="l00222"></a>00222 
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 
<a name="l00225"></a>00225 
<a name="l00232"></a>00232     <span class="keywordtype">int</span> addFileToRecv(<a class="code" href="struct_connection_1_1_____connection_info.html">ConInfo</a> &amp; recvConInfo, <a class="code" href="struct_____file_info.html" title="文件状态结构体">FileInfo</a> **pFileInfo);
<a name="l00233"></a>00233 
<a name="l00237"></a>00237     <span class="keywordtype">int</span> waitForRecv();
<a name="l00238"></a>00238 
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 
<a name="l00241"></a>00241 
<a name="l00242"></a>00242 };
<a name="l00243"></a>00243 
<a name="l00244"></a>00244 
<a name="l00245"></a>00245 <span class="preprocessor">#endif // CONNECTION_H_INCLUDED</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>类</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>枚举</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>枚举值</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2011年七月8日 星期五 15:50:01 for cute-transfer by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
